<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 实现一个函数，传入一个对象，能够返还一个新的对象内容和旧对象内容一样

    var obj = {
        name:"张三",
        obj1:{
            myname:"李四",
            age:20,
        }
        
    } -->

    <script>
      var obj1 = {
        name: "张三",
        obj2: {
          myname: "李四",
          age: 20,
        },
      };
      var obj = {};
      function fn() {
        for (var key in obj1) {
          obj[key] = obj1[key];
        }
        return obj;
      }
      fn(obj);
      console.log(obj);
    </script>
  </body>
</html>
